package com.climb.moive.service.impl;

import com.climb.moive.dao.MovieEvaluationDao;
import com.climb.moive.dao.impl.MovieEvaluationDaoImpl;
import com.climb.moive.entity.MovieEvaluation;
import com.climb.moive.exception.ApplicationException;
import com.climb.moive.service.MovieEvalService;

import java.sql.SQLException;
import java.util.List;

/**
 * @author Administrator
 * 电影文章影评业务层实现类
 */
public class MoiveEvalServiceImpl implements MovieEvalService {
    MovieEvaluationDao movieEvaluationDao=new MovieEvaluationDaoImpl();
    @Override
    public Integer countMovieEvaluationNum() {
        try {
            return movieEvaluationDao.count();
        } catch (SQLException throwables) {
            throw new ApplicationException("计算电影影评出错",throwables);
        }
    }

    @Override
    public Integer countMovieEvaluationNum(Integer memid) {
        try {
            return movieEvaluationDao.countById(memid);
        } catch (SQLException throwables) {
            throw new ApplicationException("计算个人电影影评出错",throwables);
        }
    }

    @Override
    public void delet(Integer mid) {
        try {
             movieEvaluationDao.delet(mid);
        } catch (SQLException throwables) {
            throw new ApplicationException("删除电影影评出错",throwables);
        }

    }

    @Override
    public void deleteByEid(Integer id) {
        try {
            movieEvaluationDao.deletByEvaluationId(id);
        } catch (SQLException throwables) {
            throw new ApplicationException("删除影评出错",throwables);
        }
    }

    @Override
    public MovieEvaluation findEvaByEid(Integer id) {
        try {
            return movieEvaluationDao.findEvaluationByEid(id);
        } catch (SQLException throwables) {
            throw new ApplicationException("查找影评出错",throwables);
        }
    }

    @Override
    public List<MovieEvaluation> findAllEvaluation() {
        try {
            return movieEvaluationDao.findAllEvaluation();
        } catch (SQLException throwables) {
            throw new ApplicationException("计算个人电影影评出错",throwables);
        }
    }

    @Override
    public List<MovieEvaluation> findEvaByMovieid(Integer id) {
        try {
            return movieEvaluationDao.findEvaByMovieid(id);
        } catch (SQLException throwables) {
            throw new ApplicationException("计算个人电影影评出错",throwables);
        }
    }

    @Override
    public void saveEvaluation(MovieEvaluation movieEvaluation) {
        try {
             movieEvaluationDao.saveEvaluation(movieEvaluation);
        } catch (SQLException throwables) {
            throw new ApplicationException("发表是影评出错",throwables);
        }
    }

    @Override
    public List<MovieEvaluation> findEvaluaByMemberId(Integer id) {
        try {
            return movieEvaluationDao.findEvaluaByMemberId(id);
        } catch (SQLException throwables) {
            throw new ApplicationException("计算个人电影影评出错",throwables);
        }
    }

}
